package math;

public class Matrix {

    double[][] matrix = new double[3][3];

    public Matrix( double x1 , double y1 , double z1 , double x2 , double y2 , double z2 , double x3 , double y3 , double z3 ) {
	matrix[0][0] = x1;
	matrix[1][0] = y1;
	matrix[2][0] = z1;

	matrix[0][1] = x2;
	matrix[1][1] = y2;
	matrix[2][1] = z2;

	matrix[0][2] = x3;
	matrix[1][2] = y3;
	matrix[2][2] = z3;
    }

    public Vector3D mult( Vector3D vector ) {
	double x = vector.x * matrix[0][0] + vector.y * matrix[0][1] + vector.z * matrix[0][2];
	double y = vector.x * matrix[1][0] + vector.y * matrix[1][1] + vector.z * matrix[1][2];
	double z = vector.x * matrix[2][0] + vector.y * matrix[2][1] + vector.z * matrix[2][2];
	return new Vector3D( x , y , z );
    }

    public Matrix mult( Matrix other ) {
	Matrix result = new Matrix( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );


	 for(int i = 0; i < 3; i++) {
	      for(int j = 0; j < 3; j++) {
	        for(int k = 0; k < 3; k++){
	          result.matrix[i][j] += other.matrix[i][k]*matrix[k][j];
	        }
	      }  
	     }

	return result;
    }

}
